/**
 * 简单生产领料单
 */
import request from '@/utils/httpRequest.js';
import axiosRequest from "@/utils/axiosRequest.js";


//查询仓库信息接口
export function reqWareHouseInfo () {
    return request ({
        url:"/api/stocks/warehouseList1",
        method:"get"
    })
}

//分页获取生产领料单
export const reqProductionMaterialList = (parameter) => {
    return request({
        url:"/api/stocks/list?inOrOutType=purchase",
        method:"get",
        params:parameter
    })
}

//更新某生产入库单(创建状态->生效 生效->完成)
export function reqUpdateProductionMaterial (parameter) {
    return request({
        url:"/api/stocks/updateStock1",
        method:"put",
        data:{
            inOrOutType:"materialRequisition",
            orderNumber:parameter.orderNumber,
            state:parameter.state
        }
    })
}

//根据关联单据类型获取单号列表信息
export function reqOrderNumberList(type){
    return request({
        url:"purchaseReceipts/list?type=" + type,
        method:"get"
    })
}

//根据选择的单号获取物料信息
export function reqMaterialListByOrderNum(orderNum){
    return request({
        url:"/purchaseReceipts/detail?purchasesOrderNumber=" + orderNum,
        method:"get"
    })
}

/**
 *
 * @param {*} parameter {purchasesOrderNumber  materialCode  batchNumber}
 * @returns
 */
export function reqScanRecord(parameter){
    return request({
        url:"/purchaseReceipts/list",
        method:"get",
        params:parameter
    })
}

/**
 * 2025-03-26
 */


//分页查询采购订单列表信息
export function reqPurchaseReceiptsList(parameter){
    return request({
        url:"/purchaseReceipts/list",
        method:"get",
        params:{
            page:parameter.page,
            size:parameter.size,
            purchaseCode:parameter.purchaseCode,
            customFieldOne:parameter.customFieldOne
        }
    })
}

//扫码查询采购订单
export function reqPurchaseReceiptsDetail(purchaseCode){
    return request({
        url:"/purchaseReceipts/detail",
        method:"get",
        params:{
            purchaseCode:purchaseCode
        }
    })
}

//供应商列表信息
export function reqPurchaseSuppliers(){
    return request({
        url:"/purchaseReceipts/suppliers/list",
        method:"get",
        params:{
            page:1,
            size:100,
            code:"",
            name:""
        }
    })
}

//获取当前申请人
export function reqCurrentPerson(){
    return request({
        url:"/api/users/current",
        method:"get"
    })
}

//获取申请人列表信息
export function reqUserList(){
    return request({
        url:"/api/users/list",
        method:"get",
        params:{
            page:1,
            size:100,
            nickname:""
        }
    })
}

//获取默认采购入库单号
export function reqDefaultPurchaseCode(){
    return request({
        url:"/purchaseReceipts/seCode",
        method:"get"
    })
}


//获取仓库列表信息
export function reqWarehouseList(){
    return request({
        url:"/purchaseReceipts/warehouse/all",
        method:"get"
    })
}
//获取采购订单状态数量
export function reqPurchaseStatusNum(){
    return request({
        url:"/purchaseReceipts/menu/num",
        method:"get"
    })
}
//获取入库单列表
export function reqPurchaseList(parameter){
    return request({
        url:"/purchaseReceipts/in/list",
        method:"get",
        params:parameter
    })
}

//获取入库单详情
export function reqPurchaseDetail(purchaseId){
    return request({
        url:"/purchaseReceipts/in/detail",
        method:"get",
        params:{
            id:purchaseId
        }
    })
}

//创建并完成采购入库单
export function reqCreatePurchase(parameter){
    return request({
        url:"/purchaseReceipts/in/create",
        method:"post",
        data:parameter
    })
}
//创建采购入库单
export function reqCreatePurchaseOrder(parameter){
    return request({
        url:"/purchaseReceipts/create",
        method:"post",
        data:parameter
    })
}
//更新采购入库单
export function reqUpdatePurchaseOrder(parameter){
    return request({
        url:"/purchaseReceipts/update",
        method:"post",
        data:parameter
    })
}

//获取平台编码解析规则
export const reqScanCodeRuleInfo = (flagCode) => {
    if(!flagCode){
        flagCode = 'purchaseWarehousing.handleBarcodeScan.new';
    }
    return axiosRequest({
        url:"/wms/stocks/scan/code/rule/get",
        method:"post",
        data:{
            code:flagCode
        },
        headers:{
            'jun-path':1
        }
    })
}

//根据采购单号物料号获取批次号
export const reqBarcode = (relateNumber,materialCode) => {
    return request({
        url:"/purchaseReceipts/barcode",
        method:"get",
        params:{
            relateNumber,
            materialCode
        }
    })
}

//获取标签模板接口
export const reqLabelTypes = () => {
    return request({
        url:"/labelTypes/rulesDetail2",
        method:"get",
        params:{
            ruleCode:'purchaseMaterialbarCode'
        }
    })
}

export const reqPrintLabelType = (parameter) => {
    return request({
        url:"/labelTypes/printLabel",
        method:"post",
        data:parameter
    })
}
